<script setup lang="ts">
import _axios from '@/utils/myAxios.js'
import { ref, onMounted } from 'vue'
import { ElMessage } from 'element-plus'
import { useRouter } from 'vue-router'
const router = useRouter()
const value = ref(new Date())
let userInfo = ref({
  nickname: '',
  avatar: ''
})
async function getAccountAvatar() {
    let resp = await _axios.get('/api/account/getAccountAvatar')
    if (resp.data.code == 200) {
        userInfo.value = resp.data.data
        if (userInfo.value.avatar === null) {
            userInfo.value.avatar = '/src/assets/avatar/touxiang.jpg'
        }
    } else if (resp.data.code === 401) {
        ElMessage({
            showClose: true,
            message: resp.data.message,
            type: 'error',
            appendTo: "#app",
        })
        localStorage.removeItem("Authorization")
        router.push("/login")
    } else {
        ElMessage({
            showClose: true,
            message: resp.data.message,
            type: 'error',
            appendTo: "#app",
        })
    }
}

onMounted(() => {
    getAccountAvatar()
})
</script>

<template>
  <p style="font-size: 35px;font-weight: 500;">
    <span style="font-weight: 900;margin-left: 20px;">
      {{ userInfo.nickname }}
    </span>
    欢迎来到相逢网站，相逢既是缘分
  </p>
  <el-calendar v-model="value" />
</template>

<style scoped></style>